package de.kimera.model;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

import de.kimera.api.IServicePlan;
import de.kimera.api.ITableOfHours;

public class ServicePlan implements IServicePlan {

	private Date date;
	
	private List<ITableOfHours> tableOfHours;
		
	public ServicePlan() {
		tableOfHours = new LinkedList<ITableOfHours>();
	}

	//GETTERs
	@Override
	public String getMonthString() {
		SimpleDateFormat formatter = new SimpleDateFormat("MMMMM");
		return formatter.format(date);
	}

	@Override
	public int getYear() {
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy");
		String yearString = formatter.format(date);
		return Integer.parseInt(yearString);
	}

	@Override
	public List<ITableOfHours> getTableOfHours() {
		return tableOfHours;
	}

	//SETTERs
	@Override
	public void setDate(Date date) {
		this.date = date;		
	}
	
	//OTHERs
	@Override
	public void addTableOfHours(ITableOfHours tableOfHours) {
		this.tableOfHours.add(tableOfHours);
		
		//maintain bidirectional reference
		tableOfHours.setServicePlan(this);
	}
}
